package com.example.security.config;

import com.example.security.bean.BeanConfig;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

public class CurrentUser {







    /**
     *
     * @param account
     * @return
     */
    public static String token(String  account){

        String token = Jwts.builder()
                .setSubject(account)
                .setIssuer(BeanConfig.getIssUser())
                .signWith(SignatureAlgorithm.HS512, BeanConfig.getSecret()).compact();
        return token;
    }


    /**
     *
     * @param token
     * @return
     */
    public static Claims getClaim(String token){
        return Jwts.parser()
                .requireIssuer(BeanConfig.getIssUser())
                .setSigningKey(BeanConfig.getSecret())
                .parseClaimsJws(token)
                .getBody();
    }





}
